'use strict'
import { QueryInterface, DataTypes } from 'sequelize'
import Category from '../models/category'

/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface: QueryInterface, Sequelize: typeof DataTypes) {
    await queryInterface.bulkInsert(
      'Categories',
      [
        {
          id: 1,
          name: '手机',
          parentId: null,
          createdAt: new Date(),
          updatedAt: new Date(),
        },
        {
          id: 2,
          name: '电脑',
          createdAt: new Date(),
          updatedAt: new Date(),
        },
        {
          id: 3,
          name: '智能设备',
          parentId: null,
          createdAt: new Date(),
          updatedAt: new Date(),
        },
        {
          id: 101,
          name: '智能手机',
          parentId: 1,
          createdAt: new Date(),
          updatedAt: new Date(),
        },
        {
          id: 102,
          name: '功能手机',
          parentId: 1,
          createdAt: new Date(),
          updatedAt: new Date(),
        },
        {
          id: 1001,
          name: '苹果手机',
          parentId: 101,
          createdAt: new Date(),
          updatedAt: new Date(),
        },
        {
          id: 1002,
          name: '安卓手机',
          parentId: 101,
          createdAt: new Date(),
          updatedAt: new Date(),
        },
        {
          id: 201,
          name: '笔记本电脑',
          parentId: 2,
          createdAt: new Date(),
          updatedAt: new Date(),
        },
        {
          id: 202,
          name: '台式电脑',
          parentId: 2,
          createdAt: new Date(),
          updatedAt: new Date(),
        },
        {
          id: 2001,
          name: '游戏本',
          parentId: 201,
          createdAt: new Date(),
          updatedAt: new Date(),
        },
        {
          id: 2002,
          name: '轻薄本',
          parentId: 201,
          createdAt: new Date(),
          updatedAt: new Date(),
        },
        {
          id: 301,
          name: '智能手表',
          parentId: 3,
          createdAt: new Date(),
          updatedAt: new Date(),
        },
        {
          id: 302,
          name: '智能家居',
          parentId: 3,
          createdAt: new Date(),
          updatedAt: new Date(),
        },
        {
          id: 3001,
          name: '运动手表',
          parentId: 301,
          createdAt: new Date(),
          updatedAt: new Date(),
        },
        {
          id: 3002,
          name: '健康监测手表',
          parentId: 301,
          createdAt: new Date(),
          updatedAt: new Date(),
        },
      ],
      {},
    )
  },

  async down(queryInterface: QueryInterface, Sequelize: typeof DataTypes) {
    await queryInterface.bulkDelete('Categories', [], {})
  },
}
